Funções de várias variáveis#
Vejamos agora alguns exemplos com funções de duas ou três variáveis reais com valores reais, ou seja, funções do tipo
\begin{equation*} f : \mathbb{R}^2 \to \mathbb{R} \ \ \text{ ou } \ \ f : \mathbb{R}^3 \to \mathbb{R} \end{equation*}
Os gráficos são interativos, pode arrastar, mudar o ângulo de visão, dar zoom etc.
Show code cell source
# HIDE CODE
import plotly.express as px
import plotly.graph_objects as go
import numpy as np
Exemplo#
\begin{align*} &f : \mathbb{R}^2 \to \mathbb{R} \ &f(x,y) = x^2 + y^2 \end{align*}
Show code cell source
# HIDE CODE
points = 100
proportion = 100
x = np.linspace(-proportion, proportion, points)
y = np.linspace(-proportion, proportion, points)
xGrid, yGrid = np.meshgrid(x, y)
z = xGrid**2+yGrid**2
fig = go.Figure(data=[go.Surface(x=x, y=y,z=z)])
fig.show()
O parabolóide \(z = x^2 + y^2\), o plano \(z = 70\) e a curva de nível.
Show code cell source
# HIDE CODE
points = 100
proportion = 10
x = np.linspace(-proportion, proportion, points)
y = np.linspace(-proportion, proportion, points)
teta = np.linspace(0, 2*np.pi, points)
xGrid, yGrid = np.meshgrid(x, y)
z = xGrid**2+yGrid**2
k = np.full((100, 100), 70)
fig = go.Figure(data=[go.Surface(x=x, y=y, z=z),
go.Surface(x=x, y=y, z=k, colorscale=[[0, 'green'], [1,'green']],showscale=False),
go.Scatter3d(x=np.sqrt(70)*np.cos(teta), y=np.sqrt(70)*np.sin(teta), z=np.zeros(points), mode = 'lines')
]
)
fig.show()
Show code cell source
# HIDE CODE
points = 100
proportion = 10
x = np.linspace(-proportion, proportion, points)
y = np.linspace(-proportion, proportion, points)
teta = np.linspace(0, 2*np.pi, points)
xGrid, yGrid = np.meshgrid(x, y)
z = 70 + xGrid**2+yGrid**2
data = [go.Surface(x=x, y=y, z=z),
go.Surface(),
go.Surface(x=x, y=y, z=z)
]
layout=go.Layout(
title_text="Parabolóide e curvas de nível", hovermode="closest",
updatemenus=[
{
"buttons": [
{
"args": [None, {"frame": {"duration": 20},
"mode": "immediate",
"fromcurrent": True,
"transition": {"duration": 20, "easing": "linear"}}],
"label": "▶", # play symbol
"method": "animate",
},
{
"args": [[None], {"frame": {"duration": 0},
"mode": "immediate",
"fromcurrent": True,
"transition": {"duration": 0, "easing": "linear"}}],
"label": "◼", # pause symbol
"method": "animate",
},
],
"direction": "left",
"pad": {"r": 10, "t": 70},
"type": "buttons",
"x": 0.1,
"y": 0,
}
],
scene_camera = dict(up=dict(x=0, y=0, z=1),
center=dict(x=0, y=0, z=0),
eye=dict(x=1.25, y=1.25, z=-0.25)
)
)
frames = [go.Frame(
data = [go.Surface(x=x, y=y, z=np.full((100, 100), k+70), colorscale=[[0, 'green'], [1,'green']],showscale=False),
go.Scatter3d(x=np.sqrt(k)*np.cos(teta), y=np.sqrt(k)*np.sin(teta), z=np.zeros(points), mode = 'lines', line_color='green')]
)
for k in range(1,70,1)
]
fig = go.Figure(data = data, layout = layout, frames = frames)
fig.update_layout(scene = dict(
xaxis = dict(nticks=4, range=[-10,10],),
yaxis = dict(nticks=4, range=[-10,10],),
zaxis = dict(nticks=4, range=[0,250],),),)
fig.show()
Exemplo#
\begin{align*} &f : \mathbb{R}^2 \to \mathbb{R} \ &f(x,y) = \frac{2x^2y^2}{x^2 + y^4} \end{align*}
Show code cell source
# HIDE CODE
points = 100
proportion = 100
x = np.linspace(-proportion, proportion, points)
y = np.linspace(-proportion, proportion, points)
xGrid, yGrid = np.meshgrid(x, y)
z = (2*xGrid*(yGrid**2))/(xGrid**2 + yGrid**4)
fig = go.Figure(data=[go.Surface(x=x, y=y, z=z)])
fig.show()
Exemplo#
\begin{align*} &f : \mathbb{R}^2 \to \mathbb{R} \ &f(x,y) = \frac{2xy^2}{x^2 + y^2} \end{align*}
Show code cell source
# HIDE CODE
points = 100
proportion = 100
x = np.linspace(-proportion, proportion, points)
y = np.linspace(-proportion, proportion, points)
xGrid, yGrid = np.meshgrid(x, y)
z = (2*xGrid*(yGrid**2))/(xGrid**2 + yGrid**2)
fig = go.Figure(data=[go.Surface(x=x, y=y, z=z)])
fig.show()
Exemplo#
\begin{align*} &f : \mathbb{R}^2 \to \mathbb{R} \ &f(x,y) = \frac{2xy^2}{x^2 - y^2} \end{align*}
Show code cell source
# HIDE CODE
points = 100
epsilon = 1/10
r1Grid, teta1Grid = np.mgrid[0+epsilon:1:100j, -np.pi/4 + epsilon:np.pi/4 - epsilon:100j]
r2Grid, teta2Grid = np.mgrid[0+epsilon:1:100j, np.pi/4 + epsilon:3*np.pi/4 - epsilon:100j]
r3Grid, teta3Grid = np.mgrid[0+epsilon:1:100j, 3*np.pi/4 + epsilon:5*np.pi/4 - epsilon:100j]
r4Grid, teta4Grid = np.mgrid[0+epsilon:1:100j, 5*np.pi/4 + epsilon:7*np.pi/4 - epsilon:100j]
x1 = r1Grid*np.cos(teta1Grid)
y1 = r1Grid*np.sin(teta1Grid)
z1 = 2*x1*y1**2/(x1**2-y1**2)
S1 = go.Surface(x=x1, y=y1, z=z1)
x2 = r2Grid*np.cos(teta2Grid)
y2 = r2Grid*np.sin(teta2Grid)
z2 = 2*x2*y2**2/(x2**2-y2**2)
S2 = go.Surface(x=x2, y=y2, z=z2)
x3 = r3Grid*np.cos(teta3Grid)
y3 = r3Grid*np.sin(teta3Grid)
z3 = 2*x3*y3**2/(x3**2-y3**2)
S3 = go.Surface(x=x3, y=y3, z=z3)
x4 = r4Grid*np.cos(teta4Grid)
y4 = r4Grid*np.sin(teta4Grid)
z4 = 2*x4*y4**2/(x4**2-y4**2)
S4 = go.Surface(x=x4, y=y4, z=z4)
fig = go.Figure(data=[S1,S2,S3,S4])
fig.show()
Exemplo#
\begin{align*} &f : \mathbb{R}^2 \to \mathbb{R} \ &f(x,y) = \begin{cases} e^{\frac{1}{x^2 + y^2 - 1}} & \text{ se } \ x^2 + y^2 < 1 \ 0 & \text{ se } \ x^2+y^2 \geqslant 1 \end{cases} \end{align*}
Show code cell source
# HIDE CODE
points = 100
epsilon = 1/200
r1Grid, teta1Grid = np.mgrid[0:1-epsilon:100j, -np.pi:np.pi:100j]
x1 = r1Grid*np.cos(teta1Grid)
y1 = r1Grid*np.sin(teta1Grid)
z1 = np.exp(1/(r1Grid**2-1))
S1 = go.Surface(x=x1, y=y1, z=z1, colorscale=[[0, 'blue'], [1,'yellow']],showscale=False)
r2Grid, teta2Grid = np.mgrid[1-epsilon:4:100j, -np.pi:np.pi:100j]
x2 = r2Grid*np.cos(teta2Grid)
y2 = r2Grid*np.sin(teta2Grid)
z2 = 0*r2Grid
S2 = go.Surface(x=x2, y=y2, z=z2, colorscale=[[0, 'blue'], [1,'blue']],showscale=False)
fig = go.Figure(data=[S1,S2])
fig.show()
points = 100
x0 = 7
y0 = 8
z0 = (x0**3)*(y0**2)
x = np.linspace(4, 10, points)
y = np.linspace(5, 11, points)
xGrid, yGrid = np.meshgrid(x, y)
z = (xGrid**3)*(yGrid**2)
fig = go.Figure(data=[go.Surface(z=z, x=x, y=y,colorscale=[[0, 'blue'], [1,'blue']],
showscale=False),
go.Surface(z=(z0 + 3*x0**2*y0**2*(xGrid - x0) + 2*x0**3*y0*(yGrid - y0)), x=x, y=y,
colorscale=[[0, 'red'], [1,'red']],
showscale=False)
])
fig.show()
points = 100
proportion = 10
x0 = 7
y0 = 8
z0 = -x0**2 - y0**2
x = np.linspace(-20, 20, points)
y = np.linspace(-20, 20, points)
xGrid, yGrid = np.meshgrid(x, y)
z = -xGrid**2 - yGrid**2
kx = np.full((100, 100), 7)
ky = np.full((100, 100), 1)
kz = np.full((100, 100), z0)
fig = go.Figure(data=[go.Surface(z=z, x=x, y=y,colorscale=[[0, 'blue'], [1,'blue']],
showscale=False),
go.Surface(z=(z0 - 2*x0*(xGrid - x0) - 2*y0*(yGrid - y0)), x=x, y=y,
colorscale=[[0, 'red'], [1,'red']],
showscale=False)])
fig.show()